<template>
  <ele-dialog-table :title="title" width="800px" :visible.sync="prodVisible" :formConfig="formConfig" :column="column"
    @getSelectData="getSelectProd" :getList="getList" :hasFooter="true" :otherParam="formDataDialog">
  </ele-dialog-table>
</template>

<script>
import { baseGoods, getmesProcessMaterial } from "@/api/process/mesProductProcessSteps";
import {
  prodSearchDialog,
  prodColumn,
  materialColumnNew,
  prodSearchModelDialogNew,
} from "../config.js";

export default {
  name: "selectProd",

  data() {
    return {
      title: $i18n.t("mesProductProcessSteps.modelDialogTitleProd"),
      prodVisible: false,
      formDataDialog: {},
      column: prodColumn,
      getList: baseGoods,
      formConfig: prodSearchDialog,
    };
  },

  mounted() { },

  methods: {
    init(data = {}) {
      this.getList = data.isNewApi ? baseGoods : baseGoods;
      this.formConfig = data.isNewApi
        ? prodSearchModelDialogNew
        : prodSearchDialog;
      this.column = data.isNewApi
        ? materialColumnNew
        : prodColumn;
      this.title = data.isNewApi ? $i18n.t("mesProductProcessSteps.modelDialogTitleMater") : $i18n.t("mesProductProcessSteps.modelDialogTitleProd");
      this.formDataDialog = data;
      this.$nextTick(() => {
        this.prodVisible = true;
      });
    },
    getSelectProd(data) {
      if (data.length != 1) {
        this.$message.error(this.$t("mesProductProcessSteps.modelTitleError"));
        return;
      }
      this.$emit("getSelectProd", data);
    },
  },
};
</script>

<style lang="scss" scoped></style>
